.TH ptypipe 1 "January 1, 2020"

.SH NAME
ptypipe \- turn any pipe into a TTY, with resizable window support

.SH SYNOPSIS
.B ptypipe
{ command } { arguments... }

.SH DESCRIPTION
.I ptypipe
is a small command-line utility that runs its first argument
in a pseudo terminal created with forkpty().  This is handy for the
following cases:

  * Undoing glibc\'s behavior of buffering stdin/stdout, which makes
    pipe-based wrapped command shells useless.

  * Using a different window size for programs than the controlling
    TTY.

  * Notifying a pipe-based wrapped shell that the window size has
    changed.

.SH RESIZABLE WINDOW SUPPORT

ptypipe monitors its stdin for the dtterm/xterm sequence:

.B ESC [ 8 ; { rows } ; { cols } t

If this sequence is seen, it is stripped from the input to the child
process and ioctl(TIOCSWINSZ) is executed to notify the child of a new
window size.  One could thus do something like:

/bin/echo -ne "\\033[8;20;40t" | ptypipe ls

  ...and \'ls\' will execute with a window size of 20 rows by 40 columns.

Tranquil Java (https://tjide.sourceforge.io) illustrates how ptypipe
can work for a larger program.  TJ is 100% Java, but needs to spawn
interactive terminals.  It can do this with either \'script\' or
\'ptypipe\'.  Using \'script\' results in terminal windows that cannot
be resized; using \'ptypipe\' those terminal windows resize as
expected in modern programs.

.SH SEE ALSO
.BR "script"(1), " tj"(1), " ioctl"(2)

.SH BUGS
.PP
If an ESC is in the stream ahead of a correct resize sequence, the
resize sequence is not noticed and will be emitted to the child
process.

.SH LICENSE
Copyright (C) 2021   Autumn Lamonte
.PP
Available to all under the MIT License.
